package com.technology.education.data.model

import android.os.Parcel
import android.os.Parcelable

/**
 *@author:create by BZY
 *Date: 2022/3/17 14
 * 我的邀请列表
 */

data class InviteListModel(
    val list: List<InviteList>,
    val pageNo: Int,
    val pageSize: Int,
    val total: Int
)

data class InviteList(
    val avatar: String?,
    val id: String,
    val name: String,
    val totalChargeAmount: Int,
    val totalEarnDuration: Int
):Parcelable {
    /**
     * 返回的时长为秒,这里进行转换,如果大于1小时显示小时:分钟,否则显示分钟
     */
    val durationString:String get() {
        return if (totalEarnDuration>60*60){
            "${totalEarnDuration/60/60}小时${totalEarnDuration%(60*60)}分钟"
        }else{
            "${totalEarnDuration/60}分钟"
        }
    }

    constructor(parcel: Parcel) : this(
        parcel.readString(),
        parcel.readString()?:"",
        parcel.readString()?:"",
        parcel.readInt(),
        parcel.readInt()
    ) {
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeString(avatar)
        parcel.writeString(id)
        parcel.writeString(name)
        parcel.writeInt(totalChargeAmount)
        parcel.writeInt(totalEarnDuration)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<InviteList> {
        override fun createFromParcel(parcel: Parcel): InviteList {
            return InviteList(parcel)
        }

        override fun newArray(size: Int): Array<InviteList?> {
            return arrayOfNulls(size)
        }
    }
}